package com.l024.common.exception;

import com.l024.common.utils.LogUtils;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class LoginException {
    @ExceptionHandler
    @ResponseBody
    public Map ErrorHandler(AuthorizationException e) {
        LogUtils.logInfo("没有通过权限验证！");
        Map<String,Object> map = new HashMap<>();
        map.put("code","403");
        map.put("msg","没有通过权限验证,请先登录");
        return map;
    }
}
